import { makeAutoObservable } from "mobx";
import { makePersistable } from "mobx-persist-store";

type adminInfoType = {
	username: string,
	id: number,
	role: number,
	building: string,
}
export class adminStore {
	adminInfo: adminInfoType = {
		username: '',
		id: 1,
		role: 0,
		building: 'A',
	}

	token: string = '';

	constructor() {
		makeAutoObservable(this)
		makePersistable(this, {
			name: 'UserStore',
			properties: ["adminInfo", "token"],
			storage: window.localStorage,
		})
	}

	setToken(token: string) {
		this.token = token
		window.localStorage.setItem('graduation', token)
	}

	setAdminInfo(adminInfo: adminInfoType) {
		this.adminInfo = adminInfo
	}
}